export const getLocal = (name) => {
  return localStorage.getItem(name);
};

export const setLocal = (name, value) => {
  localStorage.setItem(name, value);
};
// 获取当前时间
export const getNowDate = (data) => {
  function add0(m) {
    return m < 10 ? "0" + m : m;
  }
  if (data) {
    var time = new Date(data);
    var y = time.getFullYear();
    var m = time.getMonth() + 1;
    var d = time.getDate();
    var h = time.getHours();
    var mm = time.getMinutes();
    var s = time.getSeconds();
    return (
      y +
      "-" +
      add0(m) +
      "-" +
      add0(d) +
      " " +
      add0(h) +
      ":" +
      add0(mm) +
      ":" +
      add0(s)
    );
  } else {
    var NowDate = new Date();
    var hours =
      NowDate.getHours() < 10 ? "0" + NowDate.getHours() : NowDate.getHours();
    var minutes =
      NowDate.getMinutes() < 10
        ? "0" + NowDate.getMinutes()
        : NowDate.getMinutes();
    var seconds =
      NowDate.getSeconds() < 10
        ? "0" + NowDate.getSeconds()
        : NowDate.getSeconds();
    var time =
      NowDate.getFullYear() +
      "-" +
      (NowDate.getMonth() + 1) +
      "-" +
      NowDate.getDate() +
      " " +
      hours +
      ":" +
      minutes +
      ":" +
      seconds;
    return time;
  }
};
